#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x, pre = 0;
	long long ans = 0, cnt = 0;
	while(cin>>x)
	{
		if(pre-x == 1)
			cnt++;
		else
			cnt = 1;
		pre = x;
		ans += cnt;
	}
	cout<<ans;
	return 0;
}

